import { Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm';
import { Service } from '../../service/entities/service.entity';

@Entity('geography')
export class Geography {
  @PrimaryGeneratedColumn({ type: 'int' })
  id: number;

  @Column({
    type: 'boolean',
    comment: '是否被删除',
    default: false,
  })
  isDelete: boolean;

  @Column({
    type: 'varchar',
    comment: '类型',
    nullable: true,
    default: 'geography',
  })
  type: string;

  @Column({ type: 'varchar', comment: '省', nullable: false })
  province: string;

  @Column({ type: 'varchar', comment: '市', nullable: false })
  city: string;

  @ManyToOne(() => Service, (service) => service.geography)
  service: Service[];

  @Column({
    name: 'create_date',
    type: 'timestamp',
    comment: '创建时间',
    default: () => 'CURRENT_TIMESTAMP',
  })
  create_date: Date;

  @Column({
    name: 'update_date',
    type: 'timestamp',
    comment: '修改时间',
    nullable: true,
  })
  updated_date: Date;
}
